/**
 * @param {string[]} strs
 * @return {number}
 */
export var findLUSlength = function (strs) {
  let ans = -1
  for (let i = 0; i < strs.length; i++) {
    let checked = true
    for (let j = 0; j < strs.length; j++) {
      if (i !== j && checkIsSubstring(strs[i], strs[j])) {
        checked = false
        break
      }
    }
    if (checked) ans = Math.max(ans, strs[i].length)
  }
  return ans
}

function checkIsSubstring(str1, str2) {
  if (str1.length > str2.length) {
    return false
  }
  let i = 0
  let j = 0
  while (i < str1.length && j < str2.length) {
    if (str1[i] === str2[j]) i++
    j++
  }
  return i === str1.length
}
